<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>

<script>
description(
    "This test checks that TypedArray allocation failures should throw"
);

function shouldThrowType(_a, _type)
{
    var _exception;
    var _av;
    try {
        _av = eval(_a);
    } catch (e) {
        _exception = e;
    }

    if (_exception) {
        if (typeof _e == "undefined" || _exception.name === _type)
            testPassed(_a + " threw exception " + _exception.name + ".");
        else
            testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _type) + ". Threw exception " + _exception + ".");
    } else if (typeof _av == "undefined")
        testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _type) + ". Was undefined.");
    else
        testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _type) + ". Was " + _av + ".");
}

shouldThrowType("new ArrayBuffer(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Uint8Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Uint8ClampedArray(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Uint16Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Uint32Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Int8Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Int16Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Int32Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Float32Array(7 * 1125899906842624)", "RangeError");
shouldThrowType("new Float64Array(7 * 1125899906842624)", "RangeError");
</script>
</body>
</html>
